advertiserApp.controller("advertiserCtrl",function($scope,$http){
     $scope.todayShow = false;
	 $scope.yesterdayShow = false;
     $scope.earlierShow = false;
     //init data
     $http.post("/web-adv/getInboxList").success(function(data){
	     console.log(data);
		 $scope.arr = data;	
         if($scope.arr.today.todayNum>0){
		     $scope.todayShow = true;			 
		 }
		 if($scope.arr.yesterday.yesterdayNum>0){
		     $scope.yesterdayShow = true;		 
		 }
		 if($scope.arr.earlier.earlierNum>0){
		     $scope.earlierShow = true;
		 }
		 /* $("#pageBox").extendPagination({
		     totalCount:$scope.arr.today.pageSize*10,
             showPage: '5',
             limit: '10',
             goPage:"",
             callback:function(page){
			     //console.log(page)
				 $http.post("/web-adv/getInboxList").success(function(){
				     
				 });
			 }
		 }); */
	 });
	 //单行删除;                
	 $scope.delOneMsg = function(id){	     
	     console.log(id);
	     //console.log(id)                                         msgId
		 $.post("/web-adv/deleteMsgInbox",{msgId:id}).success(function(data){
		     console.log(data)
			 if(data.status=="1"){  //删除成功
			     //重新拉取数据   存储当前页码
				 $http.post("/web-adv/getInboxList").success(function(newData){
				     $scope.arr=newData;
					 console.log("ddd");
					 console.log(newData);
				 });
			 }else{
			     alert("删除失败！");
			 }
		 });
	 };
	 //批量删除;
	 $scope.delMore = function(){
	     var checkboxDom = $(".table").find("td").children("[type='checkbox']");
		 var checkIndex = 0;
		 for(i=0;i<checkboxDom.length;i++){
		     if(checkboxDom.eq(i)[0].checked==true){  //选中状态进行删除			     
				 checkIndex++;
				 var id = checkboxDom.eq(i).next().text();
				 $.post("/web-adv/deleteMsgInbox",{msgId:id}).success(function(data){
		         console.log(data)
			         if(data.status!="1"){  //删除成功			             
						 alert("删除失败！");
						 return false;
			         }
		         });
			 };			 
		 };
		 if(checkIndex>0){
		     //重新拉取数据   存储当前页码
			 msgUiBox("删除成功！");			
			 $http.post("/web-adv/getInboxList").success(function(data){
			     $scope.arr = data;					 
			 });
		 }
	 };	 
});
